Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correctly await async close on adapters #4971

Merged
merged 4 commits into from
Sep 14, 2024

Conversation

marknelissen
Copy link
Contributor

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

The close of the server does not await the async close operations of the adapters like the MongoAdapter, leading to errors due to premature closing of the underlying connection.

New behavior

The close awaits the async operations on the adapters of the different namespaces. This allows to be sure that e.g. the Mongo connection can be safely disposed of.

Other information (e.g. related issues)

I've chose the Promise.allSettled to avoid being too disruptive, since the current synchronous implementation already disregards any errors the closing of the adapters might raise.

@darrachequesne
Copy link
Member

Hi! Thanks for the pull request 👍

In that case, do you think it would make sense to wait for the completion of this.httpServer.close() below too?

Reference: https://nodejs.org/api/http.html#serverclosecallback

@marknelissen
Copy link
Contributor Author

That is already what is done. The only way to wait for it, is to pass the callback function, which the current code already does. It is not an awaitable function, since it does not return a Promise.

@BrandonZacharie
Copy link

@darrachequesne What else is needed to get this merged?

@marknelissen
Copy link
Contributor Author

@darrachequesne I resynced the branch. Can you approve?

@darrachequesne darrachequesne merged commit e347a3c into socketio:main Sep 14, 2024
2 checks passed
@darrachequesne
Copy link
Member

@marknelissen thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants